package com.boot.controller;

import com.boot.bean.R;
import com.boot.service.CodeExecutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/execute")
public class CodeExecutionController {

    @Autowired
    private CodeExecutionService executionService;


    @PostMapping("/python")
    public R executePython(@RequestBody String code) {
        return R.ok(executionService.executePythonCode(code));
    }

    @PostMapping("/java")
    public R executeJava(@RequestBody String code) {
        return R.ok(executionService.executeJavaCode(code));
    }

    @PostMapping("/c")
    public R executeC(@RequestBody String code) {
        return R.ok(executionService.executeCCode(code));
    }
}
